/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Alex
 */
@Entity
@Table(catalog = "", schema = "nasa")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Resposta.findAll", query = "SELECT r FROM Resposta r"),
    @NamedQuery(name = "Resposta.findByRespId", query = "SELECT r FROM Resposta r WHERE r.respId = :respId"),
    @NamedQuery(name = "Resposta.findByRespResposta", query = "SELECT r FROM Resposta r WHERE r.respResposta = :respResposta")})
public class Resposta implements Serializable, Comparable<Resposta> {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "resp_id", nullable = false)
    private Integer respId;
    @Basic(optional = false)
    @Column(name = "resp_resposta", nullable = false, length = 45)
    private String respResposta;
    @JoinColumn(name = "resp_resultado", referencedColumnName = "result_id", nullable = false)
    @ManyToOne(optional = false)
    private Resultado respResultado;

    public Resposta() {
    }

    public Resposta(Integer respId) {
        this.respId = respId;
    }

    public Resposta(Integer respId, String respResposta) {
        this.respId = respId;
        this.respResposta = respResposta;
    }

    public Resposta(Integer respId, String respResposta, Resultado respResultado) {
        this.respId = respId;
        this.respResposta = respResposta;
        this.respResultado = respResultado;
    }

    public Integer getRespId() {
        return respId;
    }

    public void setRespId(Integer respId) {
        this.respId = respId;
    }

    public String getRespResposta() {
        return respResposta;
    }

    public void setRespResposta(String respResposta) {
        this.respResposta = respResposta;
    }

    public Resultado getRespResultado() {
        return respResultado;
    }

    public void setRespResultado(Resultado respResultado) {
        this.respResultado = respResultado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (respId != null ? respId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Resposta)) {
            return false;
        }
        Resposta other = (Resposta) object;
        if ((this.respId == null && other.respId != null) || (this.respId != null && !this.respId.equals(other.respId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Resposta[ respId=" + respId + " ]";
    }

	@Override
	public int compareTo(Resposta other) {
		return Integer.parseInt(other.getRespResposta()) - Integer.parseInt(this.getRespResposta());
	}

}
